//
//  BaseTableViewController.m
//  weibo-OC
//
//  Created by diyuyma on 15/12/11.
//  Copyright © 2015年 zhangkaiyun. All rights reserved.
//

#import "BaseTableViewController.h"
#import "VisitorLoginView.h"
#import "OAuthViewController.h"
#import "UserAccountViewModel.h"
@interface BaseTableViewController () <VisitorLoginViewDelegate>

@end

@implementation BaseTableViewController

- (void)loadView {
    
    // 添加用户是否登陆标记

    self.userLogin = [[UserAccountViewModel alloc] init].userLogin;
    self.userLogin ? [super loadView] : [self loadVisitorView];
}

- (void)loadVisitorView {
    self.visitorLoginView =  [[VisitorLoginView alloc] init];
    // 设置代理
    self.visitorLoginView.visitorDelegate = self;
    self.view = self.visitorLoginView;
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"注册" style:UIBarButtonItemStylePlain target:self action:@selector(visitorWillLogin)];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"登陆" style:UIBarButtonItemStylePlain target:self action:@selector(visitorWillRegister)];
}

- (void)visitorWillLogin {
    
    NSLog(@"visitorWillLogin");
    OAuthViewController *oauth = [[OAuthViewController alloc] init];
    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:oauth];
    [self presentViewController:nav animated:YES completion:nil];
}

- (void)visitorWillRegister {
    NSLog(@"visitorWillRegister");
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
}

@end
